package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.anno.ToEasyService;
import com.sky.dto.CategoryDTO;
import com.sky.entity.Category;
import com.sky.vo.CategoryVO;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface CategoryMapper {

    Page page(CategoryDTO categoryDTO);

    @ToEasyService
    void save(Category category);

    @ToEasyService
    @Update("update category set type=#{type},name=#{name},sort=#{sort}," +
            "update_time=#{updateTime},update_user=#{updateUser} where id=#{id}")
    void update(Category category);

    @Delete("delete from category where id=#{id}")
    void delete(@Param("id") String id);

    @Update("update category set status=#{status} where id=#{id}")
    void status(String status, String id);

    @Select("select id, type, name, sort, status, create_time, update_time, create_user, update_user from category where type=#{type}")
    List<Category> list(String type);



    @Select("select count(name) from category where type = #{type}")
    Long getCategoryTotal(String type);

    @Select("select * from category")
    List<Category> getCategory();
}
